import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '../views/Layout/index.vue'
import Home from '../views/Home/Home.vue'
import Login from '../views/Login/Login.vue'
import Page404 from '../views/404.vue'

//异步加载
const Goods = ()=>import('../views/Goods/Goods.vue')
const Params = ()=>import('../views/Params/Params.vue')
const Advert = ()=>import('../views/Advert/Advert.vue')
const Order = ()=>import('../views/Order/Order.vue')
const OrderList = ()=>import('../views/Order/OrderList/index.vue')
const OrderBack = ()=>import('../views/Order/OrderBack/index.vue')

const AddGoods = ()=>import('../views/Goods/AddGoods.vue')
const Achievement = ()=>import('../views/Achievement/allShow/index.vue')
const VersionLog = ()=>import('../views/VersionLog/index.vue')


const FantasticIdeas = ()=>import('../views/FantasticIdeas/index.vue')
const User = ()=>import('../views/User/index.vue')
const Autograph = ()=>import('../views/FantasticIdeas/Autograph/Autograph.vue')
const Animation = ()=>import('../views/FantasticIdeas/Animation/index.vue')
const LuckDraw = ()=>import('../views/FantasticIdeas/LuckDraw/index.vue')
const CountDown = ()=>import('../views/FantasticIdeas/CountDown/index.vue')
const DragSort = ()=>import('../views/FantasticIdeas/DragSort/index.vue')


Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'Login',
    component: Login
  },
  {
    path: '/404',
    component: Page404,
    hidden: true
  },
  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [
      {
        path: '/home',
        name: 'Home',
        component: Home,
        // alias: '/home'
      },
      {
        path: '/goods',
        name: 'Goods',
        component: Goods
      },
      {
        path: '/add-goods',
        name: 'AddGoods',
        component: AddGoods
      },
      {
        path: '/params',
        name: 'Params',
        component: Params
      },
      {
        path: '/advert',
        name: 'Advert',
        component: Advert
      },
      {
        path: '/order',
        name: 'Order',
        component: Order,
        redirect: '/order/order-list',
        children: [
          {
            path: 'order-list',
            component: OrderList
          },
          {
            path: 'order-back',
            component: OrderBack
          }
        ]
      },
      {
        path: '/achievement',
        name: 'Achievement',
        component: Achievement,
      },
      {
        path: '/versionLog',
        name: 'VersionLog',
        component: VersionLog,
      },
      {
        path: '/fantasticIdeas',
        name: 'FantasticIdeas',
        component: FantasticIdeas,
        redirect: '/fantasticIdeas/autograph',
        children: [
          {
            path: 'autograph',
            component: Autograph
          },
          {
            path: 'animation',
            component: Animation
          },
          {
            path: 'luckDraw',
            component: LuckDraw
          },
          {
            path: 'countDown',
            component: CountDown
          },
          {
            path: 'dragSort',
            component: DragSort
          }
        ]
      },
      {
        path: '/user',
        name: 'User',
        component: User,
      }
    ]
  },
  { path: '*', redirect: '/404' }
]

const router = new VueRouter({
  // mode: 'history',//注释掉是为了打包的dist文件中能直接访问index.html
  routes
})


export default router
